/*
moxl - Modular XML Library
Copyright (c) 2007, Malcolm Sparks

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
package moxl.xpath.parser.tokenizer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import moxl.xpath.tokenizer.XPathTokenTypes;

import org.junit.Test;

public class AbbreviatedSyntaxTest1 extends SyntaxTestBase
{

	@Override
    protected String getExpression()
	{
		return "/chapter/para[@email = 'bill@microsoft.com'][5]";
	}

	@Test
	public void tokenTypes() throws Exception
	{
		assertEquals(XPathTokenTypes.OPERATOR, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.NAME_TEST, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.OPERATOR, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.NAME_TEST, toker.nextToken().getType());

		assertEquals(XPathTokenTypes.OPEN_BRACKET, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.AT_SYMBOL, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.NAME_TEST, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.WHITESPACE, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.OPERATOR, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.WHITESPACE, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.LITERAL, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.CLOSE_BRACKET, toker.nextToken().getType());

		assertEquals(XPathTokenTypes.OPEN_BRACKET, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.NUMBER, toker.nextToken().getType());
		assertEquals(XPathTokenTypes.CLOSE_BRACKET, toker.nextToken().getType());
		assertNull(toker.nextToken());
	}

	@Test
	public void images() throws Exception
	{
		assertEquals("/", toker.nextToken().getImage());
		assertEquals("chapter", toker.nextToken().getImage());
		assertEquals("/", toker.nextToken().getImage());
		assertEquals("para", toker.nextToken().getImage());
		assertEquals("[", toker.nextToken().getImage());
		assertEquals("@", toker.nextToken().getImage());
		assertEquals("email", toker.nextToken().getImage());
		assertEquals(" ", toker.nextToken().getImage());
		assertEquals("=", toker.nextToken().getImage());
		assertEquals(" ", toker.nextToken().getImage());
		assertEquals("'bill@microsoft.com'", toker.nextToken().getImage());
		assertEquals("]", toker.nextToken().getImage());
		assertEquals("[", toker.nextToken().getImage());
		assertEquals("5", toker.nextToken().getImage());
		assertEquals("]", toker.nextToken().getImage());
		assertNull(toker.nextToken());
	}

}
